; $Id: davegr1d__get.pro,v 1.7 2005/02/08 17:17:34 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveGr1D
;
; PURPOSE:
;   The DaveGr1D class extends the DaveGr class to better handle
;   plotting of 1D data ie line plots.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   DaveGr
;
; PUBLIC METHODS:
;   Display
;   Get
;   ResetLegend
;   ReserMiscGrAttribs
;   Set
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Nov, 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.
;
;###############################################################################



;===============================================================================
; DaveGr1D::Get
;
; PURPOSE:
;   Get method for class
;
; PARAMETERS:
;
; KEYWORDS:
;   lineType [out] - return the linetype index (integer)
;
;   lineSize [out] - return the line size (float)
;
;   symType [out] - return the symbol index (integer)
;
;   symSize [out] - return the symbol size (float)
;
;   lineSymFlag [out] - return the lineSymFlag which specifies whether
;                      lines, symbols or symbols+lines are to be plotted.
;
;   color [out] - return the line/symbol display color as an RGB tripplet.
;
;   maskIndex [out] - assign a list of independent axis (integer)
;                    indices to be masked.
;
;   legend [out] - an IDL structure containing plot legend attributes.
;
;   xmin [out] - return the global minimum x for all current datasets
;
;   xmax [out] - return the global maximum x for all current datasets
;
;   zmin [out] - return the global minimum z for all current datasets
;
;   zmax [out] - return the global maximum z for all current datasets
;
;   _REF_EXTRA [out] - enables keywords to passed on
;
; RETURN VALUES:
;   0 => failure
;   1 => success
;
function DaveGr1D::get, lineType=lineType, lineSize=lineSize, symType=symType, symSize=symSize, all=all, $
  lineSymFlag=lsFlag, color=color, maskIndex=maskIndex, position=pos, legend=legend, $
  xmin=xmin,xmax=xmax,zmin=zmin,zmax=zmax,_REF_EXTRA=etc

retVal = 1

pos_IsSet = 0b
if (n_elements(pos) gt 0) then pos_IsSet = 1b

if (keyword_set(all)) then begin
    pos_IsSet = 0b
    etc = (n_elements(etc) gt 0)? create_struct(etc,'all',1) : {all:1}
endif

; Return lineType
if (arg_present(lineType)) then begin
    lineType = (pos_IsSet)? (self.lineType)[pos] : self.lineType
endif

; Return lineSize
if (arg_present(lineSize)) then begin
    lineSize = (pos_IsSet)? (self.lineSize)[pos] : self.lineSize
endif

; Return symType
if (arg_present(symType)) then begin
    symType =(pos_IsSet)? (self.symType)[pos] : self.symType
endif

; Return symSize
if (arg_present(symSize)) then begin
    symSize =(pos_IsSet)? (self.symSize)[pos] : self.symSize
endif

; Return lineSymFlag
if (arg_present(lsFlag)) then begin
    lsFlag =(pos_IsSet)? (self.lineSymFlag)[pos] : self.lineSymFlag
endif

; Return myPlotType
;if (arg_present(mpType)) then begin
;    mpType = self.myPlotType
;endif

; Return myPlotTypeFlag
;if (arg_present(mpTypeFlag)) then begin
;    mpTypeFlag = self.myPlotTypeFlag
;endif

; Return color
if (arg_present(color)) then begin
    color =(pos_IsSet)? (self.color)[pos,*] : self.color
endif

; Return maskIndex
if (arg_present(maskIndex)) then begin
    if (ptr_valid(self.maskPtr)) then maskIndex = (*self.maskPtr)
endif


; global xmin,xmax,zmin,zmax for all datasets
if (arg_present(xmin) or arg_present(xmax) or arg_present(zmin) or arg_present(zmax)) then begin
    ;; get all data
    dataRef = self->IDL_CONTAINER::get(count=nData,/all)

    ;; determine minima/maxima for combine datasets
    for i = 0,nData-1 do begin
        if (not (dataRef[i])->get(xval=xval,zval=zval,offset=offset,scalefactor=scalefactor)) then $
          return, 1
        if (i eq 0) then begin
            xmin = min(xval, max=xmax)
            ;zmin = min((zval*scalefactor+offset), max=zmax)
            zmin = min(zval, max=zmax)
        endif else begin
            xmini = min(xval, max=xmaxi) ; get xmin, xmax for current data
            ;zmini = min((zval*scalefactor+offset), max=zmaxi) ; get zmin, zmax for current data
            zmini = min(zval,max=zmaxi); get zmin, zmax for current data
            xmin = (xmini < xmin) ; running xmin
            xmax = (xmaxi > xmax) ; running xmax
            zmin = (zmini < zmin) ;
            zmax = (zmaxi > zmax) ;
        endelse
    endfor
endif
         

; Return legend
if (arg_present(legend)) then begin
    legend = self.legend
endif


; Anything else is handled by the base class
if (n_elements(etc) gt 0) then begin
    retVal = (pos_IsSet)? self->DaveGr::get(position=pos, _EXTRA=etc) : self->DaveGr::get(_EXTRA=etc)
endif

return, retVal

end
