Skip to content

Commit

Permalink
#5780 - Connection points appear visually disconnected when moving mo…
Browse files Browse the repository at this point in the history
…nomers in Flex and Snake mode
  • Loading branch information
rrodionov91 committed Feb 11, 2025
1 parent 8431839 commit 29e24ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SelectRectangle implements BaseTool {
const renderer = event.target.__data__;
const drawingEntitiesToSelect: DrawingEntity[] = [];
const ModKey = isMacOs ? event.metaKey : event.ctrlKey;
let modelChanges: Command;
const modelChanges = new Command();

this.mousePositionAfterMove = this.editor.lastCursorPositionOfCanvas;
this.mousePositionBeforeMove = this.editor.lastCursorPositionOfCanvas;
Expand All @@ -168,8 +168,9 @@ class SelectRectangle implements BaseTool {
if (renderer.drawingEntity.selected) {
return;
}
modelChanges =
this.editor.drawingEntitiesManager.unselectAllDrawingEntities();
modelChanges.merge(
this.editor.drawingEntitiesManager.unselectAllDrawingEntities(),
);
SequenceRenderer.unselectEmptyAndBackboneSequenceNodes();
const { command: selectModelChanges } =
this.editor.drawingEntitiesManager.getAllSelectedEntitiesForEntities(
Expand All @@ -184,10 +185,11 @@ class SelectRectangle implements BaseTool {
...this.editor.drawingEntitiesManager.selectedEntitiesArr,
...drawingEntitiesToSelect,
];
({ command: modelChanges } =
const { command: selectModelChanges } =
this.editor.drawingEntitiesManager.getAllSelectedEntitiesForEntities(
drawingEntities,
));
);
modelChanges.merge(selectModelChanges);
} else if (renderer instanceof BaseSequenceItemRenderer && ModKey) {
let drawingEntities: DrawingEntity[] = renderer.currentChain.nodes
.map((node) => {
Expand All @@ -203,15 +205,21 @@ class SelectRectangle implements BaseTool {
(bond) => bond.firstMonomer.selected && bond.secondMonomer?.selected,
);
drawingEntities = drawingEntities.concat(bondsInsideCurrentChain);
modelChanges =
modelChanges.merge(
this.editor.drawingEntitiesManager.selectDrawingEntities(
drawingEntities,
);
),
);
} else {
modelChanges =
this.editor.drawingEntitiesManager.unselectAllDrawingEntities();
modelChanges.merge(
this.editor.drawingEntitiesManager.unselectAllDrawingEntities(),
);
SequenceRenderer.unselectEmptyAndBackboneSequenceNodes();
}

modelChanges.merge(
this.editor.drawingEntitiesManager.hideAllMonomersHoverAndAttachmentPoints(),
);
this.editor.renderersContainer.update(modelChanges);
this.setSelectedEntities();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,21 @@ export class DrawingEntitiesManager {
return command;
}

public hideAllMonomersHoverAndAttachmentPoints() {
const command = new Command();

this.monomers.forEach((monomer) => {
monomer.turnOffHover();
monomer.turnOffAttachmentPointsVisibility();

const operation = new MonomerHoverOperation(monomer, true);

command.addOperation(operation);
});

return command;
}

public addRnaPresetFromNode = (
node: Nucleotide | Nucleoside | LinkerSequenceNode,
) => {
Expand Down

0 comments on commit 29e24ca

Please sign in to comment.