This example uses a custom task in the first step. It determines the number of classes to use for ISODATA classification (in the second step) by adding two user-specified numbers in the first step. Although this is a very basic example, it demonstrates how to perform custom tasks inside of a workflow.
Copy and paste this code into the IDL Editor. Save the file as example_custom_task.pro. Then compile and run the program.
PRO custom_task_step2_stylesheet, styleSheet, _REF_EXTRA=refExtra
COMPILE_OPT IDL2
ENVIWorkflowStep.StyleSheetShowParameters, styleSheet, 'NUMBER_OF_CLASSES'
ENVIWorkflowStep.StyleSheetHideParameters, styleSheet, 'CHANGE_THRESHOLD_PERCENT'
ENVIWorkflowStep.StyleSheetHideParameters, styleSheet, 'ITERATIONS'
END
PRO custom_task_step1_execute, input_number=inputNumber, add_number=addNumber, $
output_number=outputNumber
COMPILE_OPT IDL2
outputNumber = inputNumber + addNumber
END
PRO example_custom_task
COMPILE_OPT IDL2
e = ENVI()
workflow = ENVIWorkflow()
workflow.TITLE = 'Custom Task Workflow'
step1 = ENVIWorkflowStep()
step1.TITLE = 'Compute Number of Classes'
step1.TITLE = 'Custom Task Example'
step1.TIMELINE_TITLE = 'Add Numbers'
step1.Task.AddParameter, IDLParameterUInt($
NAME='input_number', $
DISPLAY_NAME='Input Number', $
DIRECTION='input', $
DEFAULT=1)
step1.Task.AddParameter, IDLParameterUInt($
NAME='add_number', $
DISPLAY_NAME='Number to Add', $
DIRECTION='input', $
DEFAULT=1)
step1.Task.AddParameter, IDLParameterUInt($
NAME='output_number', $
DIRECTION='output')
step1.CALLBACK_EXECUTE = 'custom_task_step1_execute'
step2 = ENVIWorkflowStep()
step2.TASK = ENVITask('ISODATAClassification')
step2.TIMELINE_TITLE = 'Classify'
step2.CALLBACK_APPLY_STYLESHEET = 'custom_task_step2_stylesheet'
workflow.Connect, step1, 'OUTPUT_NUMBER', step2, 'NUMBER_OF_CLASSES'
envi.UI.CreateWorkflowDialog, workflow
END
Result:
See Also
Customize Workflows