Upload
william-holden
View
238
Download
0
Tags:
Embed Size (px)
Citation preview
Slicer3D Wizard WorkflowSlicer3D Wizard WorkflowIn KWWidgets for a year now,Includes State Machine Engine,Was used to port Slicer2’s
EMSegmentation Module (Golland, Pohl),
Funded by NA-MIC.
12/13/2007 1Kitware Inc. (Sébastien Barré)
What it looks likeWhat it looks like
12/13/2007 2Kitware Inc. (Sébastien Barré)
State Machine EngineState Machine EngineBorrows design from IGSTK’s State
Machine,Uses KWWidgets/VTK framework,Provides the basis for the Wizard
Workflow.
12/13/2007 3Kitware Inc. (Sébastien Barré)
State Machine ClassesState Machine ClassesvtkKWStateMachineState: a state vtkKWStateMachineInput: an input vtkKWStateMachineTransition: a transition vtkKWStateMachine: a state machine
Helper classes: vtkKWStateMachineCluster: a cluster of
states vtkKWStateMachineWriter: a writer
superclass vtkKWStateMachineDOTWriter: a DOT writer
12/13/2007 4Kitware Inc. (Sébastien Barré)
State Machine StateState Machine StatevtkKWStateMachineState Id: unique state ID Name: string Description: string Enter/Leave: callbacks, events
Both callbacks and events are supported, independent of the transition, can be used to bring UI, or free resources.
12/13/2007 5Kitware Inc. (Sébastien Barré)
State Machine InputState Machine InputvtkKWStateMachineInput Id: unique input ID Name: string
12/13/2007 6Kitware Inc. (Sébastien Barré)
State Machine TransitionState Machine TransitionvtkKWStateMachineTransition Id: unique transition ID OriginState: vtkKWStateMachineState Input: vtkKWStateMachineInput DestinationState:
vtkKWStateMachineState Start/End: callbacks, events
Support callback and events at beginning and end of a transition.
12/13/2007 7Kitware Inc. (Sébastien Barré)
State Machine APIState Machine APIvtkKWStateMachine AddState(state) AddInput(input) AddTransition(transition)
CreateTransition(origin_state, input, destination_state)
SetInitialState(state) GetCurrentState(state)
PushInput(input) ProcessInputs()
12/13/2007 8Kitware Inc. (Sébastien Barré)
State Machine AlgorithmState Machine AlgorithmvtkKWStateMachine’s ProcessInputs():For each input in the queue: a transition T is searched accepting the current
state C and the input, if found:
◦ T's Start() method is triggered,◦ C's Leave() method is triggered,◦ T is pushed to the history,◦ C becomes T's DestinationState,◦ CurrentStateChangedCommand and
CurrentStateChangedEvent are invoked,◦ C (i.e. T's DestinationState)'s Enter() method is
triggered,◦ T's End() method is triggered.
12/13/2007 9Kitware Inc. (Sébastien Barré)
State Machine ExampleState Machine ExampleFrom TestStateMachine.cxx :
vtkKWStateMachine *state_machine = vtkKWStateMachine::New();
...
vtkKWStateMachineState *state_1 = vtkKWStateMachineState::New();
state_1->SetName("Start");
state_machine->AddState(state_1);
...
vtkKWStateMachineInput *input_next = vtkKWStateMachineInput::New();
input_next->SetName("next");
state_machine->AddInput(input_next);
...
// Transition: state_1 / input_next => state_2
vtkKWStateMachineTransition *trans_a = vtkKWStateMachineTransition::New();
trans_a->SetOriginState(state_1);
trans_a->SetInput(input_next);
trans_a->SetDestinationState(state_2);
state_machine->AddTransition(trans_a);
...
// Transition: state_1 / skip => state_3
state_machine->CreateTransition(state_1, input_skip, state_3);
...
// Run the state machine
state_machine->SetInitialState(state_1);
state_machine->PushInput(input_next); // state_1 to state_2
state_machine->PushInput(input_invalid); // state_2 to state_2
state_machine->ProcessInputs();
12/13/2007 10Kitware Inc. (Sébastien Barré)
Wizard WorkflowWizard Workflow Uses the state machine engine and provides higher-
level classes to meet the following requirements: ◦ a wizard is a linear succession of steps (most of the time),
◦ each step may need to display specific GUI elements,
◦ one may navigate from one step to the next one using a 'Next' button,
◦ one may navigate from one step to the previous one using a 'Back' button,
◦ one may navigate directly to the last step using a 'Finish' button,
◦ one needs to make sure a step is valid before navigating to the next one,
◦ one do *not* need to make sure a step is valid before navigating to the previous one.
12/13/2007 11Kitware Inc. (Sébastien Barré)
Wizard Workflow ClassesWizard Workflow ClassesvtkKWWizardStep: a wizard step, vtkKWWizardWorkflow: a wizard workflow,vtkKWWizardWidget: a wizard widget,
embedding buttons, client area, and a wizard workflow engine,
vtkKWWizardDialog: a wizard dialog, embedding a wizard widget in a toplevel dialog.
12/13/2007 12Kitware Inc. (Sébastien Barré)
Wizard StepWizard StepA wizard step is not a subclass of a state
machine state but an aggregation of several states, transitions and inputs that are relevant to a step.
InteractionState, ValidationState ValidationTransition, ValidationFailedTransition ValidationInput, ValidationSucceededInput,
ValidationFailedInput GoToSelfInput, GoBackToSelfInput
BUT what really needs to be re-implemented: ShowUserInterface(): brings UI Validate(): pushes inputs
Optionally: HideUserInterface() CanGoToSelf()
12/13/2007 13Kitware Inc. (Sébastien Barré)
Wizard WorkflowWizard WorkflowA wizard workflow is a subclass of a state
machine engine. It provides additional methods that accept wizard steps as arguments and:
setup their internal elements, initialize their states, connect their transitions, Distribute/reshuffle all internal elements to the
state machine superclass. A wizard workflow can be used as a regular
state machine if you wish.
12/13/2007 14Kitware Inc. (Sébastien Barré)
Wizard Workflow APIWizard Workflow API AddStep(step) CreateNextTransition(origin_step, next_input,
dest_step) CreateBackTransition(origin_step, dest_step) AddNextStep(step) … CreateGoToTransitionsToFinishStep()
Supports navigation and transition history.
12/13/2007 15Kitware Inc. (Sébastien Barré)
Wizard Workflow ExampleWizard Workflow ExampleKWWidgets CVS Cxx/Examples/WizardDialog Simple wizard walks you through a
mathematical operation: Select a mathematical operator (addition, division, square
root), Select the first operand, Select the second operand *if* the operator was addition or
division, Display the result.
Exercises simple features: Skipping a step (if the operator is square root, the second
operand is not needed), Validation (if the operand is division, the second operand
should be != 0, if the operand is square root, it should be >= 0).
12/13/2007 16Kitware Inc. (Sébastien Barré)
Wizard Workflow ExampleWizard Workflow Example Demo
12/13/2007 17Kitware Inc. (Sébastien Barré)
Diagram without “Go To Finish” transitions.
Wizard Workflow ExampleWizard Workflow Example
12/13/2007 18Kitware Inc. (Sébastien Barré)
Diagram with “Go To Finish” transitions.
“Complexity delusion”
Wizard Workflow ExampleWizard Workflow Example
12/13/2007 19Kitware Inc. (Sébastien Barré)
ResourcesResourceshttp://kwwidgets.orghttp://kwwidgets.org/Wiki/KWWidgets/
Wizard_Workflow (under construction)KWWidgets CVS: Cxx/Examples/WizardDialogSlicer SVN: Modules/EMSegment/Wizard
12/13/2007 20Kitware Inc. (Sébastien Barré)