; $Id: davegr__set.pro,v 1.8 2006/04/27 17:18:42 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveGr
;
; PURPOSE:
;   This DaveGr class defines an entity which consists of one or more
;   datasets and all the necessary properties or attributes to display
;   or plot the dataset(s). A dataset is contained in a DaveDat
;   object and can be manipulated using that class' methods.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   IDL_CONTAINER
;
; PUBLIC METHODS:
;   Add
;   Get
;   Remove
;   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.
;
;###############################################################################



;===============================================================================
; DaveGr::Set
;
; PURPOSE:
;   Set method for class.
;
; PARAMETERS:
;
; KEYWORDS:
;   title [in] - text to be used for the main plot title
;
;   nameTag [in] - A string name tag used for identifying this
;                  object's icon in a widget application.
;
;   label [in] - A variable (an ANNOTATE structure) specifying a text
;                label to be associated with the DaveGr object
;                created.
;
;   nlabel [in] - Set the number of text labels
;
;   bgColor [in] - an [R,G,B] vector of byte values to be used as the
;                  background color when displaying this object.
;
;   xColor [in] - an [R,G,B] vector of byte values specifying the
;                 x-axis color.
;
;   xFont [in] - a string specifying a valid font family name for the
;                x-axis.
;
;   xFontSize [in] - an integer specifying a valid fontsize for the
;                    x-axis.
;
;   xLabel [in] - a string specifying the label for the x-axis.
;
;   xLineSize [in] - a float specifying a valid line thickness for
;                    drawing the x-axis.
;
;   xMiscAttribs [in] - a structure specifying various graphics
;                       attributes for the x-axis.
;
;   zColor [in] - dependent-axis equivalent of xColor
;
;   zFont [in] - dependent-axis equivalent of xFont
;
;   zFontSize [in] - dependent-axis equivalent of xFontSize
;
;   zLabel [in] - dependent-axis equivalent of xLabel
;
;   zLineSize [in] - dependent-axis equivalent of xLineSize
;
;   zMiscAttribs [in] - a structure specifying various graphics
;                       attributes for the z-axis.
;
; RETURN VALUE:
;   0 => failure
;   1 => success.
;
function DaveGr::set, label=label,nlabel=nlabel,title=title,nameTag=nameTag,bgColor=bgColor, $
  xColor=xColor,xFontVal=xFont,xFontSize=xFontSize,xLabel=xLabel,xLineSize=xLineSize, $
  zColor=zColor,zFontVal=zFont,zFontSize=zFontSize,zLabel=zLabel,zLineSize=zLineSize, $
  xMiscAttribs=xMiscAttribs,zMiscAttribs=zMiscAttribs,visRef=visRef

; reset !error_state structure, ie clear all errors
message,/reset

;use this to return a fail condition if at least one error is encountered
retVal = 1

; Visualization object
if (n_elements(visRef)) then self.visRef = visRef

; title
if (n_elements(title) gt 0) then begin
    ;; make sure title is a valid ANNOTATE structure
    if (vartype(title) eq 'ANNOTATE') then begin
        self.title = title
    endif
endif

; nlabel: nos of labels - used to reset to an arbitrary nos
if (n_elements(nLabel) gt 0) then self.nLabel = 0 > nLabel < self.maxLabel

; label keyword
if (n_elements(label) gt 0) then begin
    ;; make sure value is an ANNOTATE structure
    if(vartype(label) eq 'ANNOTATE') then begin
        len = n_elements(label) < self.maxLabel
        self.label[0:len-1] = label[0:len-1]
        self.nLabel = len
    endif else begin
        !error_state.msg = 'DaveGr::set: label keyword value should be an ANNOTATE structure'
        !error_state.code = -1
        return, 0
    endelse
endif

; set miscellaneous graph attributes for x-axis
if (n_elements(xMiscAttribs)) then begin
    ;; make sure value is a valid structure
    if(vartype(xMiscAttribs) eq 'MISCGRATTRIBS') then self.xMiscAttribs = xMiscAttribs
endif

; set miscellaneous graph attributes for z-axis
if (n_elements(zMiscAttribs)) then begin
    ;; make sure value is a valid structure
    if(vartype(zMiscAttribs) eq 'MISCGRATTRIBS') then self.zMiscAttribs = zMiscAttribs
endif

; name tag
if (n_elements(nameTag)) then begin
    if (vartype(nameTag) eq 'STRING') then self.nameTag = nameTag
endif

; xFont
if (n_elements(xFont) gt 0) then begin
    if (vartype(xFont) eq 'STRING') then self.xFont = xFont
endif

; xFontSize
if (n_elements(xFontSize) gt 0) then begin
    self.xFontSize = xFontSize
endif

; xLineSize
if (n_elements(xLineSize) gt 0) then begin
    self.xLineSize = xLineSize
endif

; xColor
if (n_elements(xColor) gt 0) then begin
    dim = size(xColor)
    if ( (dim[0] eq 1) and (dim[1] eq 3)) then self.xColor = xColor
endif

; zFont
if (n_elements(zFont) gt 0) then begin
    if (vartype(zFont) eq 'STRING') then self.zFont = zFont
endif

; zFontSize
if (n_elements(zFontSize) gt 0) then begin
    self.zFontSize = zFontSize
endif

; zLineSize
if (n_elements(zLineSize) gt 0) then begin
    self.zLineSize = zLineSize
endif

; zColor
if (n_elements(zColor) gt 0) then begin
    dim = size(zColor)
    if ( (dim[0] eq 1) and (dim[1] eq 3)) then self.zColor = zColor
endif

; bgColor
if (n_elements(bgColor) gt 0) then begin
    dim = size(bgColor)
    if ( (dim[0] eq 1) and (dim[1] eq 3)) then self.bgColor = bgColor
endif

; xLabel
if (n_elements(xLabel) gt 0) then begin
    if (vartype(xLabel) eq 'STRING') then self.xLabel = xLabel
endif

; zLabel
if (n_elements(zLabel) gt 0) then begin
    if (vartype(zLabel) eq 'STRING') then self.zLabel = zLabel
endif

return, retVal
end
