Chapter 7: Creating an Operation 173
iTool Developer’s Guide Creating a New Generalized Operation
; Make sure we have a valid iTool object.
IF ~ OBJ_VALID(oTool) THEN RETURN, OBJ_NEW()
; Get the selected objects
oTargets = oTool->GetSelectedItems()
; Select only IDLitVisSurface objects. If there are
; no surface objects selected, return a null object.
surfaces = OBJ_NEW()
FOR i = 0, N_ELEMENTS(oTargets)-1 DO BEGIN
IF (OBJ_ISA(oTargets[i], 'IDLitVisSurface')) THEN BEGIN
surfaces = OBJ_VALID(surfaces[0]) ? $
[surfaces, oTargets[i]] : oTargets[i]
ENDIF
ENDFOR
IF (~OBJ_VALID(surfaces[0])) THEN RETURN, OBJ_NEW()
; Create a command set:
oCmdSet = self->IDLitOperation::DoAction(oTool)
; Record the initial values
IF (~ self->RecordInitialValues(oCmdSet, surfaces, '')) THEN $
BEGIN
OBJ_DESTROY, oCmdSet
RETURN, OBJ_NEW()
ENDIF
; Increment the style index for each surface.
FOR i = 0, N_ELEMENTS(surfaces)-1 DO BEGIN
; Retrieve the current surface style and increment it
surfaces[i]->GetProperty, STYLE = styleIndex
IF styleIndex eq 6 THEN BEGIN
styleIndex = 0
ENDIF ELSE BEGIN
styleIndex += 1
ENDELSE
; Set the new surface style
surfaces[i]->SetProperty, STYLE = styleIndex
ENDFOR
oTool->RefreshCurrentWindow
; Record the final values
result = self->RecordFinalValues(oCmdSet, surfaces, '')
RETURN, oCmdSet
Comments to this Manuals