Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slicer3D Wizard Workflow In KWWidgets for a year now,KWWidgets Includes State Machine Engine, Was used to port Slicer2s EMSegmentation Module (Golland,

Similar presentations

Presentation on theme: "Slicer3D Wizard Workflow In KWWidgets for a year now,KWWidgets Includes State Machine Engine, Was used to port Slicer2s EMSegmentation Module (Golland,"— Presentation transcript:

1 Slicer3D Wizard Workflow In KWWidgets for a year now,KWWidgets Includes State Machine Engine, Was used to port Slicer2s EMSegmentation Module (Golland, Pohl), Funded by NA-MIC.NA-MIC 12/13/20071Kitware Inc. (Sébastien Barré)

2 What it looks like 12/13/20072Kitware Inc. (Sébastien Barré)

3 State Machine Engine Borrows design from IGSTKs State Machine,IGSTK Uses KWWidgets/VTK framework, Provides the basis for the Wizard Workflow. 12/13/20073Kitware Inc. (Sébastien Barré)

4 State Machine Classes vtkKWStateMachineState: a state vtkKWStateMachineState vtkKWStateMachineInput: an input vtkKWStateMachineInput vtkKWStateMachineTransition: a transition vtkKWStateMachineTransition vtkKWStateMachine: a state machine vtkKWStateMachine Helper classes: vtkKWStateMachineCluster: a cluster of states vtkKWStateMachineCluster vtkKWStateMachineWriter: a writer superclass vtkKWStateMachineWriter vtkKWStateMachineDOTWriter: a DOT writer vtkKWStateMachineDOTWriter 12/13/20074Kitware Inc. (Sébastien Barré)

5 State Machine State vtkKWStateMachineState 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/20075Kitware Inc. (Sébastien Barré)

6 State Machine Input vtkKWStateMachineInput Id: unique input ID Name: string 12/13/20076Kitware Inc. (Sébastien Barré)

7 State Machine Transition vtkKWStateMachineTransition 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/20077Kitware Inc. (Sébastien Barré)

8 State Machine API vtkKWStateMachine AddState(state) AddInput(input) AddTransition(transition) CreateTransition(origin_state, input, destination_state) SetInitialState(state) GetCurrentState(state) PushInput(input) ProcessInputs() 12/13/20078Kitware Inc. (Sébastien Barré)

9 State Machine Algorithm vtkKWStateMachines 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/20079Kitware Inc. (Sébastien Barré)

10 State Machine Example From TestStateMachine.cxx : 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/200710Kitware Inc. (Sébastien Barré)

11 Wizard 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/200711Kitware Inc. (Sébastien Barré)

12 Wizard Workflow Classes vtkKWWizardStep: a wizard step, vtkKWWizardStep vtkKWWizardWorkflow: a wizard workflow, vtkKWWizardWorkflow vtkKWWizardWidget: a wizard widget, embedding buttons, client area, and a wizard workflow engine, vtkKWWizardWidget vtkKWWizardDialog: a wizard dialog, embedding a wizard widget in a toplevel dialog. vtkKWWizardDialog 12/13/200712Kitware Inc. (Sébastien Barré)

13 Wizard Step A 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/200713Kitware Inc. (Sébastien Barré)

14 Wizard Workflow A 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/200714Kitware Inc. (Sébastien Barré)

15 Wizard 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/200715Kitware Inc. (Sébastien Barré)

16 Wizard Workflow Example KWWidgets CVS Cxx/Examples/WizardDialogCxx/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/200716Kitware Inc. (Sébastien Barré)

17 Wizard Workflow Example Demo 12/13/200717Kitware Inc. (Sébastien Barré)

18 Diagram without Go To Finish transitions. Wizard Workflow Example 12/13/200718Kitware Inc. (Sébastien Barré)

19 Diagram with Go To Finish transitions. Complexity delusion Wizard Workflow Example 12/13/200719Kitware Inc. (Sébastien Barré)

20 Resources ow (under construction) ow KWWidgets CVS: Cxx/Examples/WizardDialogCxx/Examples/WizardDialog Slicer SVN: Modules/EMSegment/Wizard 12/13/200720Kitware Inc. (Sébastien Barré)

Download ppt "Slicer3D Wizard Workflow In KWWidgets for a year now,KWWidgets Includes State Machine Engine, Was used to port Slicer2s EMSegmentation Module (Golland,"

Similar presentations

Ads by Google