; $Id: davedat2d__get.pro,v 1.8 2005/02/08 17:17:34 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveDat2D
;
; PURPOSE:
;   This class encapsulates a DAVE formated dataset containing 2D
;   data.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   DaveDat
;
; PUBLIC METHODS:
;   Clone
;   Get
;   Print
;   Rebin
;   ResetData
;   Restore
;   Set
;   Transpose
;   XSpec
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Oct, 2002
;
; 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.
;
;###############################################################################



;===============================================================================
; DaveDat2D::get
;
; PURPOSE:
;   Main get method for class. Used to retrieve class variables (all
;   class variables are 'protected' in IDL). 
;   This method extends DaveDat::get and relies heavily on it.
;
; PARAMETERS:
;
; KEYWORDS:
;   updDavePtr [out] - Return a _pointer_ to a _copy_ of the object's
;                      updated davePtr if present. It includes any
;                      monifications that might have been performed on
;                      the dataset so far (eg a rebinning)
;
;   transpose [out] - returns a flag indicating transpose state of the
;                     data 0=>not transposed, 1=>transposed (ie x and
;                     y axis are swapped).
;
;   yVal [out] - returns a float 1D vector containing the y-axis values.
;
;   yLabel [out] - returns y-axis label as string
;
;   yType [out] - returns y-axis type as string
;
;   yUnits [out] - returns y-axis units as string
;
;   yDir [out] - a flag indicating whether the y-axis is increasing (=0) or
;                decreasing (=1) in value.
;
;   _REF_EXTRA - allows keywords to be passed to the base class (see
;                DaveDat::get).
;
; RETURN VALUE: 
;   0 => failure
;   1 => sucess.
;
function DaveDat2D::get, _REF_EXTRA=etc, yVal=yval, yLabel=ylabel, yType=ytype, yUnits=yunits, $
  updDavePtr=updDavePtr, yDir=yDir, transpose=transpose

retVal = 1

; 
if (arg_present(transpose)) then begin
    transpose = self.transposeFlag
endif

; 
if (arg_present(yDir)) then begin
    yDir = self.yDir
endif

;  y-axis values
if (arg_present(yval)) then begin
    if (ptr_valid(self.yvPtr)) then yval = (*self.yvPtr)
endif

; y-axis label
if (arg_present(ylabel)) then begin
    ylabel = self.yLabel
endif

; y-axis type
if (arg_present(ytype)) then begin
    ytype = self.yType
endif

; y-axis units
if (arg_present(yunits)) then begin
    yunits = self.yUnits
endif

; get davePtr with data updated to reflect current state of this object
if (arg_present(updDavePtr)) then begin
    if (ptr_valid(updDavePtr)) then heap_free, updDavePtr ; delete the heap variable if defined already
    if (ptr_valid(self.davePtr)) then dave_beast_ops,'dup',self.davePtr,updDavePtr
    ;; copy object's data to new davePtr
    if (ptr_valid(self.treatPtr)) then begin 
        (*(*(*updDavePtr).dataStrPtr).commonStr.treatmentPtr) = (*self.treatPtr)
    endif
    void = self->get(xval=xval,yval=yval,zval=zval,zerr=zerr)
    ; If the xaxis was reversed, undo it
    if (self.xDir eq 1) then begin
        xval = reverse(xval)
        zval = reverse(zval)
        zerr = reverse(zerr)
    endif
    ; If the yaxis was reversed, undo it
    if (self.yDir eq 1) then begin
        yval = reverse(yval)
        zval = reverse(zval,2)
        zerr = reverse(zerr,2)
    endif

    (*(*(*updDavePtr).dataStrPtr).commonStr.histPtr) = {qty:zval,err:zerr,x:xval,y:yval}
    (*(*updDavePtr).descriPtr) = (*self.descriPtr)

    ;; update remainder of commonStr    
    (*(*updDavePtr).dataStrPtr).commonStr.xtype = self.xType
    (*(*updDavePtr).dataStrPtr).commonStr.xlabel = self.xLabel
    (*(*updDavePtr).dataStrPtr).commonStr.xunits = self.xUnits
    
    (*(*updDavePtr).dataStrPtr).commonStr.ytype = self.yType
    (*(*updDavePtr).dataStrPtr).commonStr.ylabel = self.yLabel
    (*(*updDavePtr).dataStrPtr).commonStr.yunits = self.yUnits
    
    (*(*updDavePtr).dataStrPtr).commonStr.histlabel = self.zLabel
    (*(*updDavePtr).dataStrPtr).commonStr.histunits = self.zUnits
endif


; Anything else is handled by the base class
if (n_elements(etc) gt 0) then begin
    retVal = self->DaveDat::get(_EXTRA=etc)
endif

return, retVal
end
;_______________________________________________________________________________
