A SERVICE OF

logo

Chapter 7: Creating an Operation 187
iTool Developer’s Guide Example: Data Resample Operation
Init Method
FUNCTION example1_opresample::Init, _REF_EXTRA = _extra
IF (~ self->IDLitDataOperation::Init(NAME='Resample', $
TYPES=['IDLVECTOR','IDLARRAY2D','IDLARRAY3D'], $
DESCRIPTION="Resampling", _EXTRA = _extra)) THEN $
RETURN, 0
; Default values for resampling factors.
self._x = 2
self._y = 2
self._z = 2
; Register properties
self->RegisterProperty, 'X', /FLOAT, $
DESCRIPTION='X resampling factor.'
self->RegisterProperty, 'Y', /FLOAT, $
DESCRIPTION='Y resampling factor.'
self->RegisterProperty, 'Z', /FLOAT, $
DESCRIPTION='Z resampling factor.'
self->RegisterProperty, 'METHOD', $
ENUMLIST=['Nearest neighbor', 'Linear', 'Cubic'], $
NAME='Interpolation method', $
DESCRIPTION='Interpolation method.'
IF (N_ELEMENTS(_extra) GT 0) THEN $
self->example1_opresample::SetProperty, _EXTRA = _extra
; Unhide the SHOW_EXECUTION_UI property.
self->SetPropertyAttribute, 'SHOW_EXECUTION_UI', HIDE=0
RETURN, 1
END
Discussion
The first item in our class definition file is the Init method. The Init method’s
function signature is defined first, using the class name example1_opresample. The
_REF_EXTRA keyword inheritance mechanism allows any keywords specified in a
call to the Init method to be passed through to routines that are called within the Init
method even if we do not know the names of those keywords in advance.