From a5a54a76faba52a4d7d47a6fcbe665d2835994b1 Mon Sep 17 00:00:00 2001 From: David Doty Date: Tue, 18 Jan 2022 16:04:09 +0000 Subject: [PATCH] fixed bug with displaying strand and domain names where the React components were not being passed the helix svg positions causing a crash --- lib/src/app.dart | 4 ++-- lib/src/view/design_main_strand.dart | 18 +++++++++++++++--- .../design_main_strand_and_domain_names.dart | 9 +++++++++ .../view/design_main_strand_strand_name.dart | 6 ++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/src/app.dart b/lib/src/app.dart index 322a79b99..4ab10b9af 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -39,8 +39,8 @@ import 'actions/actions.dart' as actions; App app; const SCADNANO_PROD = String.fromEnvironment('SCADNANO_PROD'); -const USE_REDUX_DEV_TOOLS = SCADNANO_PROD != 'true'; -// const USE_REDUX_DEV_TOOLS = false; +// const USE_REDUX_DEV_TOOLS = SCADNANO_PROD != 'true'; +const USE_REDUX_DEV_TOOLS = false; const RUN_TEST_CODE_INSTEAD_OF_APP = false; //const RUN_TEST_CODE_INSTEAD_OF_APP = true; diff --git a/lib/src/view/design_main_strand.dart b/lib/src/view/design_main_strand.dart index 832edd5d1..db55dfad2 100644 --- a/lib/src/view/design_main_strand.dart +++ b/lib/src/view/design_main_strand.dart @@ -97,6 +97,15 @@ class DesignMainStrandComponent extends UiComponent2 classname += ' ' + constants.css_selector_scaffold; } + // only store enough of helix svg positions for helices this strand has + Map> helix_idx_to_svg_position_y_map_on_strand_unbuilt = {}; + for (var domain in props.strand.domains) { + helix_idx_to_svg_position_y_map_on_strand_unbuilt[domain.helix] = + props.helix_idx_to_svg_position_map[domain.helix]; + } + BuiltMap> helix_idx_to_svg_position_y_map_on_strand = + helix_idx_to_svg_position_y_map_on_strand_unbuilt.build(); + return (Dom.g() ..id = props.strand.id ..onPointerDown = handle_click_down @@ -119,7 +128,7 @@ class DesignMainStrandComponent extends UiComponent2 ..drawing_potential_crossover = props.drawing_potential_crossover ..moving_dna_ends = props.moving_dna_ends ..geometry = props.geometry - ..helix_idx_to_svg_position_map = props.helix_idx_to_svg_position_map + ..helix_idx_to_svg_position_map = helix_idx_to_svg_position_y_map_on_strand ..only_display_selected_helices = props.only_display_selected_helices)(), _insertions(), _deletions(), @@ -134,6 +143,7 @@ class DesignMainStrandComponent extends UiComponent2 ..only_display_selected_helices = props.only_display_selected_helices ..show_domain_names = props.show_domain_names ..show_strand_names = props.show_strand_names + ..helix_idx_to_svg_position_y_map = helix_idx_to_svg_position_y_map_on_strand ..domain_name_font_size = props.domain_name_font_size ..strand_name_font_size = props.strand_name_font_size ..key = 'domain-names')(), @@ -148,7 +158,8 @@ class DesignMainStrandComponent extends UiComponent2 ..selected_modifications_in_strand = props.selected_modifications_in_strand ..font_size = props.modification_font_size ..display_connector = props.modification_display_connector - ..helix_idx_to_svg_position_y_map = props.helix_idx_to_svg_position_map.map((i, p) => MapEntry(i, p.y)) + ..helix_idx_to_svg_position_y_map = + props.helix_idx_to_svg_position_map.map((i, p) => MapEntry(i, p.y)) ..key = 'modifications')(), ]); } @@ -160,7 +171,8 @@ class DesignMainStrandComponent extends UiComponent2 // select/deselect props.strand.handle_selection_mouse_down(event); // set up drag detection for moving DNA ends - var address = util.find_closest_address(event, props.helices.values, props.groups, props.geometry, props.helix_idx_to_svg_position_map); + var address = util.find_closest_address( + event, props.helices.values, props.groups, props.geometry, props.helix_idx_to_svg_position_map); HelixGroup group = app.state.design.group_of_strand(props.strand); var helices_view_order_inverse = group.helices_view_order_inverse; app.dispatch(actions.StrandsMoveStartSelectedStrands( diff --git a/lib/src/view/design_main_strand_and_domain_names.dart b/lib/src/view/design_main_strand_and_domain_names.dart index df989067c..e8a013cfb 100644 --- a/lib/src/view/design_main_strand_and_domain_names.dart +++ b/lib/src/view/design_main_strand_and_domain_names.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:built_collection/built_collection.dart'; import 'package:over_react/over_react.dart'; @@ -36,6 +38,8 @@ mixin DesignMainStrandAndDomainNamesPropsMixin on UiProps { bool show_strand_names; int domain_name_font_size; int strand_name_font_size; + + BuiltMap> helix_idx_to_svg_position_y_map; } class DesignMainStrandAndDomainNamesProps = UiProps @@ -85,6 +89,8 @@ class DesignMainStrandAndDomainNamesComponent extends UiComponent2 start_svg = props.helix.svg_base_pos(props.domain.start, props.domain.forward, props.helix_svg_position_y); - Point end_svg = props.helix.svg_base_pos(props.domain.end - 1, props.domain.forward, props.helix_svg_position_y); + Point start_svg = + props.helix.svg_base_pos(props.domain.start, props.domain.forward, props.helix_svg_position_y); + Point end_svg = + props.helix.svg_base_pos(props.domain.end - 1, props.domain.forward, props.helix_svg_position_y); Point mid_svg = (start_svg + end_svg) * 0.5; String baseline = props.domain.forward ? 'baseline' : 'hanging';