;+
; PROJECT:
;       HESSI
;
; NAME:
;       HESSI IMAGE FILE CLASS DEFINITION
;
; PURPOSE:
;       This class is used to create a pseudo image object from a saved data structure.
;       It is a pseudo object in the sense that everything is set directly into
;       the object and gets and getdatas just return what was set, no further processing
;       is allowed.  The purpose is to allow us to use the existing hsi_image object methods.
;       This is not intended to work on its own (altough it
;       should), use hsi_image() as access layer.
;
;       See also the hsi_image_howto at:
;       http://hessi.ssl.berkeley.edu/~csillag/rhessi/hsi_image_howto.html
;
; CATEGORY:
;       HESSI Imaging
;
; CONSTRUCTION:
;       obj = Obj_Name( 'hsi_image' )
;       obj = hsi_image()
;
; INPUT:
;		DATA_STRUCT - Structure containing all information and data to set in object.
;       Input to this object is in the form of a saved_data structure.  The saved_data
;       structures are usually created by the HESSI GUI.  They contain:
;          ** Structure PLOTMAN_SAVED_DATA, 8 tags, length=56, data length=56:
;           DATA            POINTER   <PtrHeapVar1075>
;           XAXIS           POINTER   <PtrHeapVar1076>
;           YAXIS           POINTER   <PtrHeapVar1077>
;           CONTROL         POINTER   <PtrHeapVar1078>
;           INFO            POINTER   <PtrHeapVar1083>
;           CLASS           STRING    'HSI_IMAGE'
;           CLASS_NAME      STRING    ''
;           SAVE_MODE       STRING    'obj_extract'
;       Set this into the object via:
;           obj -> set, data_struct=data_struct
;           or on creation via obj = hsi_image(data_struct=data_struct)
;       The control, info, and data from this structure will be set into the object.
;       No more sets will be allowed (they will not have an effect), but obj->get(...) will
;       return the control and info parameters as usual, and obj->getdata() will return the
;       image array.
;
; EXAMPLES:
;       Note this object can be created directly, but is most useful when used from plotman.
;       If pl is a plotman object, then to create an object from the 3rd panel (which must be
;       a HESSI Image panel:
;         panels = pl -> get(/panels)
;         panel3 = panels -> get_item(3)
;         obj = hsi_image(data_str=(*panel3).saved_data)
;
; SEE ALSO:
;       hsi_image
;       hsi_image_strategy
;       hsi_image_raw
;       hsi_image_file
;
; Modifications:
;
; Written:  Kim Tolbert 22-Jan-2005

;--------------------------------------------------------------------

FUNCTION hsi_image_pseudo::INIT, SOURCE = source, _ref_EXTRA=extra

ret = self -> hsi_image_strategy::init( $
                                        control = hsi_image_file_control(), $
                                        source = source )

IF Keyword_Set( extra ) THEN self -> Set, _EXTRA = extra

RETURN, ret

END

;----------------------------------------------------------

pro hsi_image_pseudo::set,   $
	data_struct=data_struct, $
	_extra = _extra

if keyword_set(_extra) then self -> hsi_image_file::set, _extra=_extra

if keyword_set(data_struct) then begin
	ptr_free, self.data_struct
	self.data_struct=ptr_new(data_struct)
endif

end

;----------------------------------------------------------

pro hsi_image_pseudo::process, _EXTRA = _extra

if ptr_valid(self.data_struct) then $
	self -> hsi_image_file::process, data_struct=*self.data_struct, _extra=_extra ;else $
;		self->setdata, -1
if not ptr_valid(self.data) then self -> setdata,-1
; reset the following since we don't know what was in the info in data_struct
self -> set, n_images_done=1, /use_single, use_all=0
self->set, need_update = 0
end

;--------------------------------------------------------------------

PRO hsi_image_pseudo__define

self = {hsi_image_pseudo, $
		data_struct: ptr_new(), $
        INHERITS hsi_image_file }

END

;---------------------------------------------------------------------------
; End of 'hsi_image_file__define.pro'.
;---------------------------------------------------------------------------
