; $Id: davedat2d__resetdata.pro,v 1.6 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::resetData
;
; PURPOSE:
;   This method is used to 
;   ** set (initially) most of the DaveDat class variables or 
;   ** reset them (subsequestly).
;   The values to be set/reset are taken from the davePtr class variable
;   which, once set, would typically remain unaltered for the lifetime of
;   an object.
;   This method extends DaveDat::resetData
;
; PARAMETERS:
;
; KEYWORDS:
;   skipbase [in] - if set, then skip call to DaveDat::resetData() method during
;                   class initialization. 
;
; RETURN VALUE:
;   0 => failure
;   1 => success
;
function DaveDat2D::resetData, skipbase=skipbase

if (not keyword_set(skipbase)) then begin
    ;; first call the base class resetData method
    if (self->DaveDat::resetData() ne 1) then return, 0
endif 


; set/reset remaining class variables
if (ptr_valid(self.yvPtr)) then begin ; reset
    (*self.yvPtr) = (*(*(*self.davePtr).dataStrPtr).commonStr.histPtr).y
endif else begin                ; set
    self.yvPtr = ptr_new((*(*(*self.davePtr).dataStrPtr).commonStr.histPtr).y)
endelse

; Check if y-axis is not increasing with index then reverse it
self.yDir = 0
ny = n_elements((*self.yvPtr))
if ((*self.yvPtr)[ny-1] lt (*self.yvPtr)[0]) then begin
    self.yDir = 1
    (*self.yvPtr) = reverse((*self.yvPtr))
    (*self.zvPtr) = reverse((*self.zvPtr),2)    
    (*self.zePtr) = reverse((*self.zePtr),2)    
endif

self.yLabel = (*(*self.davePtr).dataStrPtr).commonStr.ylabel
self.yType = (*(*self.davePtr).dataStrPtr).commonStr.ytype
self.yUnits = (*(*self.davePtr).dataStrPtr).commonStr.yunits 

; yType must be defined!
if (strlen(strtrim(self.yType,2)) eq 0) then self.yType = 'POINTS'

; transposeFlag - reset to 0
self.transposeFlag = 0

return, 1
end 
;_______________________________________________________________________________



