; $Id: fdavetas.pro,v 1.7 2005/02/09 14:02:27 azuah Exp $
;###############################################################################
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################
;*******************************************************************************
;23456789 123456789 123456789 123465798 123456789 123456789 123465789 123456789
;       10        20        30        40        50        60        70        80
;*******************************************************************************
pro fdaveTAS, event

   widget_control,event.top,get_uvalue = pState,/no_copy
   widget_control,event.id, get_uvalue = uval

   thisEvent = tag_names(event,/structure_name)
     ; Structure name is the name of the event.

   case thisEvent of

     'WIDGET_BUTTON':$
      begin
         widget_control,event.top,set_uvalue = pState,/no_copy
         daveDeSensitizeButtons, event
         widget_control,event.top,get_uvalue = pState,/no_copy
         inPtr = (*pState).davePtr

       case dave_valid( inPtr ) of
         1: message $
          , 'Good DAVEPTR is being passed from DAVE to TAS programs.' $
          , /continue
         else: message $
          , 'DAVEPTR is damaged or empty. Please be warned.' $
          , /continue
       endcase

         case uval of
           'PSD': begin
            o = obj_new('trifenestra', [event.id, event.top], inPtr, group_leader = event.top)
           end

      'XP': begin
            tasxp_launcher, [event.id, event.top], inPtr, group_leader = event.top
           end

      'EXAMINE': begin
         tas_examine, [event.id, event.top], inPtr, group_leader = event.top
      end

      else: begin
      end
         endcase
      end
     'WIDGET_TREE_SEL':$
      begin
         widget_control,event.top,set_uvalue = pState,/no_copy
         daveDeSensitizeButtons, event
         widget_control,event.top,get_uvalue = pState,/no_copy
         inPtr = (*pState).davePtr

       case dave_valid( inPtr ) of
         1: message $
          , 'Good DAVEPTR is being passed from DAVE to TAS programs.' $
          , /continue
         else: message $
          , 'DAVEPTR is damaged or empty. Please be warned.' $
          , /continue
       endcase

         case uval of
           'PSD': begin
            o = obj_new('trifenestra', [event.id, event.top], inPtr, group_leader = event.top)
           end

      'XP': begin
            tasxp_launcher, [event.id, event.top], inPtr, group_leader = event.top
           end

      'EXAMINE': begin
         tas_examine, [event.id, event.top], inPtr, group_leader = event.top
      end

      else: begin
      end
         endcase
      end
     'TASREDUCEEVENT': $
      begin
        case dave_valid( event.inPtr ) of
         1: message, $
           'Good InPtr is passed to DAVE.' $
           , /continue
         else: message, $
           'No or damaged InPTR is passed to DAVE. Be Warned.' $
           , /continue
      endcase
      if not ptr_valid( (*pState).davePtr ) then begin
         (*pState).davePtr = ptr_new(/allocate_heap)
      endif
        *(*pState).davePtr = *event.inPtr

        case dave_valid( (*pState).davePtr ) of
         1: message, $
           'Good DAVEPTR is passed to DAVE.' $
           , /continue
         else: message, $
           'No or damaged DAVEPTR is passed to DAVE. Be Warned.' $
           , /continue
      endcase

        widget_control,event.top,set_uvalue = pState,/no_copy
        daveSensitizeButtons,event
        widget_control,event.top,get_uvalue = pState,/no_copy
      end

     else:
   endcase

   widget_control,event.top,set_uvalue = pState,/no_copy
   return
end
;*******************************************************************************
;23456789 123456789 123456789 123465798 123456789 123456789 123465789 123456789
;       10        20        30        40        50        60        70        80
;*******************************************************************************