# Progress on the task subsystem

**URL:** <https://discourse.kitware.com/t/progress-on-the-task-subsystem/982>\
**Category:** Design\
**Created:** [February 22, 2023, 3:02pm UTC](https://discourse.kitware.com/t/progress-on-the-task-subsystem/982 "2023-02-22T15:02:39Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [February 26, 2023, 7:40am UTC](https://discourse.kitware.com/t/progress-on-the-task-subsystem/982/5 "2023-02-26T07:40:49Z")

</div>

Some more progress:

- Nodes vary in width so the task title can be shown with a color swatch showing the task status to the left (also in the tool-tip):  
 ![Screenshot from 2023-02-26 01-53-54](https://discourse.kitware.com/uploads/default/original/1X/c4b07db4d6587b564e86a8d496a6aab11f5f299e.png)
- Nodes that are unavailable may be dragged but the tool-button title cannot be triggered, so they cannot be marked active.
- Nodes that are incomplete or better do expose a menu at the right of their title:  
 ![Screenshot from 2023-02-26 01-54-17](https://discourse.kitware.com/uploads/default/original/1X/a781bc5d681979afff92851fbee6b820479225f2.png)  
Note that in the screenshot above – because “Load a model and attribute” is incomplete – the task cannot be marked completed.
- Marking a task complete is possible from the GUI.
- Switching the active task is possible from the GUI.

Finally, here’s a simplified wind-tunnel example from John.

 ![Screenshot from 2023-03-01 02-29-51](https://discourse.kitware.com/uploads/default/original/1X/3ca0186f37009092a76fdff5554c466240fd8e96.png)

## Remaining Work

There’s still a lot left to do. Here are some suggestions if people want to work on things related to tasks:

- @aron.helser Add reactions (especially setting the active view in the attribute editor) when switching active tasks. Hints for implementing:
  - Add a `styles()` method to `smtk::task::Manager` that returns a JSON object like the [example here](https://discourse.kitware.com/t/design-issues-around-tasks-and-projects/931).
  - Have the attribute editor panel observe the project manager. When a project is available, have it observe the “active” task on project’s task-manager (see `smtk::task::Active::Observers`).
  - When the active task changes, examine the new task’s styles and, if any has an `attribute-editor` entry, parse that to discover a view name.

- ~~Lay out nodes automatically.~~
- @johnt Save/restore user-edited node layout.
  - The placement of tasks in the task-panel exists only in the Qt layer (each `qtTaskNode` has a position and is held by the `qtTaskScene`, in turn held by a `qtTaskEditor`, in turn held by a `pqSMTKTaskPanel`). Either we need to move node placement to be part of the `smtk::task::Task` instance or we need an API with no Qt dependencies to query where nodes are placed in a view. Hints for implementing:
  - The most expedient solution is simply to add ivars to `smtk::task::Task` and have `qtTaskNode` set these each time its layout is changed. Then, `smtk/task/json/jsonTask.cxx` could include the nodal locations in its own serialization (and deserialize as needed).
  - Beyond that, the automatic layout that currently occurs when a new project becomes active in the task panel would need to be omitted if nodal locations already exist.

- Provide some UI for GatherResources that lets users select from among a project’s resources. Hints for implementing:
  - Create a new `qtGatherResources` which inherits `qtBaseView`.
  - Register the class with the `smtk::view::Manager`’s `viewWidgetFactory`.
  - Extend `qtTaskNode` to create a view widget for its “contents” and display it inside the `m_controls` groupBox (this group box is declared in `smtk/extension/qt/task/TaskNode.ui`).
  - This should probably be done after the “Add reactions…” item above since the name of the view configuration for a task node should be part of the task’s style.

- Fix a bug that prevents task adaptors from running properly (UUIDs of gathered resources are not communicated to other tasks).
- Handle groups of tasks more gracefully. (Choose a layout strategy.)
- Streamline interactions with task-nodes for usability (e.g., click or double-click task title button to activate without using a pop-up menu; click a task status “completable” swatch to mark completed). Implementation hints:
  - Decide on a set of improved interactions. Suggestions include
    - Clicking on the task title should make it active if possible.
    - Clicking on the task status swatch should mark it completed/completable if it was completable/completed to begin with. (Other states should have no effect.)
    - When a task becomes active, if it has a `node-view` style, the `m_controls` widget should be shown. When a task is no longer active, its `m_controls` widget should be hidden (i.e., always auto-expand the active task and auto-collapse inactive ones). This does not prevent users from re-expanding nodes later.
    - Hovering over a task should display a tool-tip with the task’s status followed by its brief description.
    - A task should have some affordance to show a complete description to users.

  - Decide whether to stick with Qt widgets embedded in a `QGraphicsItem` or to subclass a `QGraphicsItem` that draws the title, state-swatch, drag-handle, and context-menu button. The latter seems like more maintenance but with more intuitive interaction.

- Implement [resource schemas](https://discourse.kitware.com/t/versioning-resources-in-smtk) (i.e., renaming the attribute resource’s `template` and `templateVersion` methods to `schema` and `schemaVersion` respectively, then moving them up to `smtk::resource::Resource`). By making resource schemas a “thing,” we can put task definitions in objects that are progenitors to resources.

---

_[View the full topic](https://discourse.kitware.com/t/progress-on-the-task-subsystem/982)._
