Skip to content

Commit

Permalink
added ability to exclude scaffolds from selection when using "select …
Browse files Browse the repository at this point in the history
…all with same..."
  • Loading branch information
dave-doty committed Feb 11, 2024
1 parent e16239d commit 34ba098
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/src/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1571,9 +1571,13 @@ abstract class SelectAllWithSameAsSelected

BuiltList<SelectableTrait> get traits;

bool get exclude_scaffolds;

/************************ begin BuiltValue boilerplate ************************/
factory SelectAllWithSameAsSelected({BuiltList<Selectable> templates, BuiltList<SelectableTrait> traits}) =
_$SelectAllWithSameAsSelected._;
factory SelectAllWithSameAsSelected(
{BuiltList<Selectable> templates,
BuiltList<SelectableTrait> traits,
bool exclude_scaffolds}) = _$SelectAllWithSameAsSelected._;

SelectAllWithSameAsSelected._();

Expand Down
1 change: 1 addition & 0 deletions lib/src/reducers/selection_reducer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ SelectablesStore select_all_with_same_reducer(
var selected_strands = selectables_store.selected_strands.toList();
for (var strand in state.design.strands) {
if (selected_strands.contains(strand)) continue;
if (action.exclude_scaffolds && strand.is_scaffold) continue;
bool include_strand = true;
// by default include the strand; now go looking for a trait where it doesn't match
for (var trait in trait_values.keys) {
Expand Down
7 changes: 6 additions & 1 deletion lib/src/state/selectable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,15 @@ Future<void> ask_for_select_all_with_same_as_selected() async {
}

var all_traits = List<SelectableTrait>.from(SelectableTrait.values);
var items = List<DialogItem>.filled(all_traits.length, null);
var items = List<DialogItem>.filled(all_traits.length + 1, null);

for (int idx = 0; idx < all_traits.length; idx++) {
var trait = all_traits[idx];
items[idx] = DialogCheckbox(label: trait.description, value: false);
}
items[all_traits.length] = DialogCheckbox(label: '(Exclude scaffold(s))', value: false, tooltip: '''\
If checked, then only strands that are not scaffolds will be selected.
However, *currently* selected scaffold strands will remain selected.''');

var dialog = Dialog(
title: "Select all strands with same traits as currently selected strand(s)",
Expand All @@ -693,10 +696,12 @@ Future<void> ask_for_select_all_with_same_as_selected() async {
traits_for_selection.add(trait);
}
}
bool exclude_scaffolds = (results[all_traits.length] as DialogCheckbox).value;

var action = actions.SelectAllWithSameAsSelected(
templates: selected_strands,
traits: traits_for_selection.build(),
exclude_scaffolds: exclude_scaffolds,
);
app.dispatch(action);
}

0 comments on commit 34ba098

Please sign in to comment.