; $Id: davegr2d__get.pro,v 1.10 2006/08/31 17:57:38 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveGr2D
;
; PURPOSE:
;   The DaveGr2D class extends the DaveGr class to better handle
;   plotting of 2D data ie area and surface plots.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   DaveGr
;
; PUBLIC METHODS:
;   Display
;   Get
;   ReserMiscGrAttribs
;   Set
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Dec, 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.
;
;###############################################################################



;===============================================================================
; DaveGr2D::Get
;
; PURPOSE:
;   Get method for class
;
; PARAMETERS:
;
; KEYWORDS:
;   plotType [out] - plot type ('contour'|'image'|'surface').
;
;   yColor [out] - y-axis color (RGB).
;
;   yFontVal [out] - y-axis font family name.
;
;   yFontSize [out] - y-axis fontsize
;
;   yLabel [out] - the y-axis label.
;
;   yLineSize [out] - y-axis line thickness.
;
;   yMiscAttribs [out] - a structure containing various y-axis graphics
;                       attributes.
;
;   xmin [out] - return minimum x value for dataset
;
;   xmax [out] - return maximum x value for dataset
;
;   ymin [out] - return minimum y value for dataset
;
;   ymax [out] - return maximum y value for dataset
;
;   zmin [out] - return minimum z value for dataset
;
;   zmax [out] - return maximum z value for dataset
;
;   _REF_EXTRA [out] - enables keywords to be passed on
;
; RETURN VALUES:
;   0 => failure
;   1 => success
;
function DaveGr2D::get, plotType=plotType $
  ,yFontVal=yFont,yColor=yColor,yFontSize=yFontSize,yLabel=yLabel,yLineSize=yLineSize,fgColor=fgColor $
  ,fillflag=fillflag, nlevels=nlevels,shadeflag=shadeflag,palette=palette,style=style $
  ,interpFlag=interpFlag,skirtFlag=skirtFlag,skirtValue=skirtValue,hiddenLineFlag=hlFlag $ 
  ,vertShadeFlag=vertShadeFlag,bottomFlag=bottomFlag,bottomColor=bottomColor,colorIndex=colorIndex $
  ,ambLightInt=alInt,posLightInt=plInt,posLightLoc=plLoc,posLightFlag=plFlag,ambLightFlag=alFlag $
  ,posLightDir=plDir,yMiscAttribs=yMiscAttribs,transpose=transpose $
  ,xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax,zmin=zmin,zmax=zmax $
  ,cLabelFlag=cLabelFlag,cLabelInt=cLabelInt,cLabelDist=cLabelDist,downhillFlag=downhillFlag $
  ,cLinestyle=cLinestyle,cThick=cThick $
  ,_REF_EXTRA=etc

retVal = 1

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

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

; y axis Color
if (arg_present(yColor)) then begin
    yColor = self.yColor
endif

; y axis Font
if (arg_present(yFont)) then begin
    yFont = self.yFont
endif

; y axis FontSize
if (arg_present(yFontSize)) then begin
    yFontSize = self.yFontSize
endif

; y axis LineSize
if (arg_present(yLineSize)) then begin
    yLineSize = self.yLineSize
endif

; y axis Label
if (arg_present(yLabel)) then begin
    yLabel = self.yLabel
endif

; foreground Color
if (arg_present(fgColor)) then begin
    fgColor = self.fgColor
endif

; Return color Index
if (arg_present(colorIndex)) then begin
    colorIndex = self.colorIndex
endif

; color palette
if (arg_present(palette)) then begin
    palette = self.palette
endif

; Return fillflag
if (arg_present(fillflag)) then begin
    if (self.plotType eq 'CONTOUR') then $
      fillflag = (*self.plotAttribPtr).fillflag $
    else $
      retVal = 0
endif

; Return cLabelFlag
if (arg_present(cLabelFlag)) then begin
    if (self.plotType eq 'CONTOUR') then $
      cLabelFlag = (*self.plotAttribPtr).cLabelFlag $
    else $
      retVal = 0
endif

; Return cLabelInt
if (arg_present(cLabelInt)) then begin
    if (self.plotType eq 'CONTOUR') then $
      cLabelInt = (*self.plotAttribPtr).cLabelInt $
    else $
      retVal = 0
endif

; Return cLabelDist
if (arg_present(cLabelDist)) then begin
    if (self.plotType eq 'CONTOUR') then $
      cLabelDist = (*self.plotAttribPtr).cLabelDist $
    else $
      retVal = 0
endif

; Return downhillFlag
if (arg_present(downhillFlag)) then begin
    if (self.plotType eq 'CONTOUR') then $
      downhillFlag = (*self.plotAttribPtr).downhillFlag $
    else $
      retVal = 0
endif

; Return cLinestyle
if (arg_present(cLinestyle)) then begin
    if (self.plotType eq 'CONTOUR') then $
      cLinestyle = (*self.plotAttribPtr).cLinestyle $
    else $
      retVal = 0
endif

; Return cThick
if (arg_present(cThick)) then begin
    if (self.plotType eq 'CONTOUR') then $
      cThick = (*self.plotAttribPtr).cThick $
    else $
      retVal = 0
endif

; Return bottomflag
if (arg_present(bottomflag)) then begin
    if (self.plotType eq 'SURFACE') then $
      bottomflag = (*self.plotAttribPtr).bottomflag $
    else $
      retVal = 0
endif

; Return bottomColor
if (arg_present(bottomColor)) then begin
    if (self.plotType eq 'SURFACE') then $
      bottomColor = (*self.plotAttribPtr).bottomColor $
    else $
      retVal = 0
endif

; Return nlevels
if (arg_present(nlevels)) then begin
    if (self.plotType eq 'CONTOUR') then $
      nlevels = (*self.plotAttribPtr).nlevels $
    else $
      retVal = 0
endif

; Return shadeflag
if (arg_present(shadeflag)) then begin
    if (self.plotType ne 'IMAGE') then $
      shadeflag = (*self.plotAttribPtr).shadeflag $
    else $
      retVal = 0
endif

; Return vertShadeFlag
if (arg_present(vertShadeFlag)) then begin
    if (self.plotType eq 'SURFACE') then $
      vertShadeFlag = (*self.plotAttribPtr).vertShadeFlag $
    else $
      retVal = 0
endif

; Return interpFlag
if (arg_present(interpflag)) then begin
    if (self.plotType eq 'IMAGE') then $
      interpflag = (*self.plotAttribPtr).interpflag $
    else $
      retVal = 0
endif

; Return skirtflag
if (arg_present(skirtflag)) then begin
    if (self.plotType eq 'SURFACE') then $
      skirtFlag = (*self.plotAttribPtr).skirtFlag $
    else $
      retVal = 0
endif

; Return skirtValue
if (arg_present(skirtValue)) then begin
    if (self.plotType eq 'SURFACE') then $
      skirtValue = (*self.plotAttribPtr).skirtValue $
    else $
      retVal = 0
endif

; Return hiddenLineFlag
if (arg_present(hlFlag)) then begin
    if (self.plotType eq 'SURFACE') then $
      hlFlag = (*self.plotAttribPtr).hiddenLineFlag $
    else $
      retVal = 0
endif

; Return style
if (arg_present(style)) then begin
    if (self.plotType eq 'SURFACE') then $
      style = (*self.plotAttribPtr).style $
    else $
      retVal = 0
endif

; Return ambient light intensity
if (arg_present(alInt)) then begin
    if (self.plotType eq 'SURFACE') then $
      alInt = (*self.plotAttribPtr).ambLightInt $
    else $
      retVal = 0
endif

; Return ambient light Flag
if (arg_present(alFlag)) then begin
    if (self.plotType eq 'SURFACE') then $
      alFlag = (*self.plotAttribPtr).ambLightFlag $
    else $
      retVal = 0
endif

; Return Positional light intensity
if (arg_present(plInt)) then begin
    if (self.plotType eq 'SURFACE') then $
      plInt = (*self.plotAttribPtr).posLightInt $
    else $
      retVal = 0
endif

; Return positional light Flag
if (arg_present(plFlag)) then begin
    if (self.plotType eq 'SURFACE') then $
      plFlag = (*self.plotAttribPtr).posLightFlag $
    else $
      retVal = 0
endif

; Return Positional light location
if (arg_present(plLoc)) then begin
    if (self.plotType eq 'SURFACE') then $
      plLoc = (*self.plotAttribPtr).posLightLoc $
    else $
      retVal = 0
endif

; Return Positional light direction
if (arg_present(plDir)) then begin
    if (self.plotType eq 'SURFACE') then $
      plDir = (*self.plotAttribPtr).posLightDir $
    else $
      retVal = 0
endif

; Return miscellaneous graph attributes for z-axis
if (arg_present(yMiscAttribs)) then begin
    yMiscAttribs = self.yMiscAttribs
endif

; global xmin,xmax,ymin,ymax,zmin,zmax for all datasets
if (arg_present(xmin) or arg_present(xmax) or $
    arg_present(ymin) or arg_present(ymax) 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,yval=yval,zval=zval,offset=offset,scalefactor=scalefactor)) then $
          return, 1
        if (i eq 0) then begin
            xmin = min(xval, max=xmax)
            ymin = min(yval, max=ymax)
            ;zmin = min(zval*scalefactor, max=zmax)
            zmin = min(zval, max=zmax)
        endif else begin
            xmini = min(xval, max=xmaxi) ; get xmin, xmax for current data
            ymini = min(xval, max=ymaxi) ; get ymin, ymax for current data
            ;zmini = min(zval*scalefactor, 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
            ymin = (ymini < ymin) ; running xmin
            ymax = (ymaxi > ymax) ; running xmax
            zmin = (zmini < zmin) ;
            zmax = (zmaxi > zmax) ;
        endelse
    endfor
endif

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

return, retVal

end
