; $Id: davegr1d__define.pro,v 1.10 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::Cleanup
;
; PURPOSE:
;   Cleanup method for objects of this class
;
; PARAMETERS:
;
pro DaveGr1D::cleanup

if (ptr_valid(self.maskPtr)) then ptr_free, self.maskPtr

; call base class cleanup method
self->DaveGr::cleanup

end
;-------------------------------------------------------------------------------



;===============================================================================
; DaveGr1D::Init
;
; PURPOSE:
;   Initialization method for objects of this class
;
; PARAMETERS:
;
; KEYWORDS:
;   _EXTRA [in] - Allows keywords to be passed to based class (see
;                 DaveGr::Init).
;
; RETURN VALUE:
;   0 => failure
;   1 => success.
;
function DaveGr1D::init, _EXTRA=etc 

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

; if a dataObj keyword was passed make sure that it's value
; is a DaveDat1D object
; then call base class initialization after
if (n_elements(etc) gt 0) then begin
    res = where(tag_names(etc) eq 'DATAREF', dataRef_isSet)
    if (dataRef_isSet gt 0) then begin
        if (vartype((etc.dataRef)[0]) ne 'DAVEDAT1D') then begin
            !error_state.msg = 'DaveGr1D::init: invalid object reference (dataRef) passed'
            !error_state.code = -1
            return, 0
        endif
    endif 
endif
if (self->DaveGr::init(_EXTRA=etc) ne 1) then return, 0 ; base class initialization

; Set default values for class variables. Use the x-axis type
; (points/histogram) to determine default values.
if (self->count() gt 0) then begin
    if (self->get(dataRef=dataRef)) then begin
        for i=0,n_elements(dataRef)-1 do begin
            if (dataRef[i]->get(xtype=xtype)) then begin
                case strmid(strupcase(xtype),0,4) of
                    'HIST': self.lineSymFlag[i] = 0
                    
                    'POIN': self.lineSymFlag[i] = 1
                    
                    else: self.lineSymFlag[i] = 1
                endcase
            endif else begin
                self.lineSymFlag[*] = 1 ; set to POINTS
            endelse
        endfor 
    endif else begin
        self.lineSymFlag[*] = 1 ; set to POINTS
    endelse
endif
self.lineType = 0               ; solid line
self.lineSize = 1.0             ;
self.symType = 6                ; Square
self.symSize = 1.5              ;
self.color = 255b   ; 'WHITE'


; Initialize miscellaneous axes graph attributes
self->resetMiscGrAttribs

; Initialize legend properties
self->resetLegend

return, 1

end
;-------------------------------------------------------------------------------



;===============================================================================
; DaveGr1D__define
;
; PURPOSE:
;   Class structure definition procedure
;
; PARAMETERS:
;
; KEYWORDS:
;
pro DaveGr1D__define

nDataMax = 50

legend = {LegendStr, $
          bkgdColor:[0b,0b,0b], $ ; bkgd color 
          font:'', $            ; item font
          fontsize:0.0, $       ; item fontsize
          tFont:'', $           ; legend title font
          tFontsize:0.0, $      ; legend title fontsize
          title:'', $           ; legend title
          tColor:[0b,0b,0b], $  ; legend title color
          gap:0.0, $            ; gap between items
          gWidth:0.0, $         ; width of glyphs
          hideFlag:0b, $        ; hide legend flag: 0-yes; 1-no
          fillFlag:1b, $        ; fill bkgd flag: 0-no, 1-yes
          outlFlag:1b, $        ; outline (border) flag: 0-no, 1-yes
          outlColor:[0b,0b,0b], $ ; outline (border) color
          outlThick:0.0, $      ; thickness of outline
          textColor:[0b,0b,0b], $ ; item text color
          location:[0.0,0.0] , $ ; legend location in normalised units
          itemName:strarr(nDataMax), $ ; item names
          itemThick:fltarr(nDataMax) $ ; item thicknesses
         }

void = {DaveGr1D, $
        lineSymFlag:bytarr(nDataMax), $ ; specifies display type: 0 - lines; 1 - symbols; 2 - lines+symbols
        lineType:bytarr(nDataMax), $ ; line style eg solid, dash etc
        lineSize:fltarr(nDataMax)+1.0, $ ; thickness of line
        symType:bytarr(nDataMax)+6b, $ ; symbol type - default is square
        symSize:fltarr(nDataMax)+1.0, $ ; symbol size
        color:bytarr(nDataMax,3)+255b, $ ; line/symbol display color - uses a custom (16) color table; 1 --> WHITE
        maskPtr:ptr_new(), $    ; ptr to an array of masked x-axis indices
        legend:{legendStr}, $   ; legend
        inherits DaveGr $       ; 
       }

end
